ImagXpress 13 for .NET - User Guide > How To > Use the New Multi-Page TIFF Edit API > Insert Multiple Pages |
The InsertPage method inserts a single page from one source TIFF file into another destination TIFF file. The InsertPage method allows the first page of a source multi-page TIFF file or a single page TIFF file to be inserted into a destination TIFF file.
The InsertPages method supports setting a starting page in a source multi-page TIFF file and setting the number of pages to be inserted from the source TIFF file into the destination TIFF file.
The ImageX.InsertPage method looks like this:
C# Example |
Copy Code
|
---|---|
public static void InsertPage( ImagXpress imagXpress, string srcFileName, string dstFileName, int pageNumber ) ImageX.InsertPage(imagXpress, srcFileName, dstFileName, pageNumber); |
The ImageX.InsertPages looks like this:
C# Example |
Copy Code
|
---|---|
public static void InsertPages( ImagXpress imagXpress, string sourceFilename, int sourcePageNumber, int numberOfPages, string destinationFilename, int destinationPageNumber ) ImageX.InsertPages(imagXpress, sourceFilename, sourcePageNumber, numberOfPages, destinationFilename, destinationPageNumber); |
Using ImageX.InsertPage to insert the first 3 pages of a multipage TIFF document into another document requires code similar to the following:
Copy Code
|
|
---|---|
System.IO.File.Copy(sourceFilename, tempSourceFilename); for (int i = 1; i <= 3; i++) { ImageX.InsertPage(imagXpress1, tempSourceFilename, destinationFilename, i); ImageX.DeletePage(imagXpress1, tempSourceFilename, 1); } |
The same task can be done with ImageX.InsertPages with the following code:
Copy Code
|
|
---|---|
ImageX.InsertPages(imagXpress1, sourceFilename, 1, 3, destinationFilename, 1); |
Using the ImageX.InsertPage method to append the first 3 pages of one TIFF document to the end of another TIFF document required code similar to this:
Copy Code
|
|
---|---|
int numberOfPagesInDocument = ImageX.NumPages(imagXpress1, destinationFilename); int startPageToAppend = numberOfPagesInDocument + 1; System.IO.File.Copy(sourceFilename, tempSourceFilename); for (int i = 0; i < 3; i++) { ImageX.InsertPage(imagXpress1, tempSourceFilename, destinationFilename, startPageToAppend + i); ImageX.DeletePage(imagXpress1, tempSourceFilename, 1); } |
The same task can be done using ImageX.InsertPages with the following code:
Copy Code
|
|
---|---|
ImageX.InsertPages(imagXpress1, sourceFilename, 1, 3, destinationFilename, int.MaxValue);
|
Using the int.MaxValue above signals to the InsertPages method the intention to append to the end of the document. Setting any value greater than the number of pages in the destination file will append it to the end of the file.